// ts-node study.ts

// 二维数组合并去重

let a1 = [{
    id:"a1",name:"张珊"
},{id:"a2",name:"张珊1"},{id:"a3",name:"张珊2"}]


let a2 = [{
    id:"a5",name:"张珊"
},{id:"a2",name:"张珊1"},{id:"a6",name:"张珊2"}]


function mergeUniqueArrays(a1: any[], a2: any[]): any[] {
    let result: any[] = [];
    a1.forEach(item => {
        if (!result.some(existingItem => existingItem.id === item.id)) {
            result.push(item);
        }
    });
    a2.forEach(item => {
        if (!result.some(existingItem => existingItem.id === item.id)) {
            result.push(item);
        }
    });
    return result;
}

// 使用函数并输出结果
console.log(mergeUniqueArrays(a1, a2));